package dxc02;

import dxc02.MyRunnable;

public class demo2 {
    public static void main(String[] args) {
           /*
            setPriority(int newPriority)        设置线程的优先级
            final int getPriority()             获取线程的优先级
       */
        //创建线程要执行的参数对象
        MyRunnable mr = new MyRunnable();
        //创建线程对象
        Thread t1 = new Thread(mr,"线程1");
        Thread t2 = new Thread(mr,"线程2");
        t1.setPriority(1);//设置那个线程的优先级高，就说明该程序先运行的结束的概率大
        //优先级越高，抢占的cpu的机率就越大
        //java默认的优先级是5
        t2.setPriority(10);
        t1.start();
        t2.start();
    }
}
